<?php

declare(strict_types=1);

namespace app\validate;

use think\Validate;

class ArticleVal extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'title' => ['require', 'length' => '5,20'],
        'cat_id' => ['require'],
        'content' => ['require'],
        'abstract' => ['length' => '0,150']
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.require' => '标题不可为空',
        'title.length' => '标题必须为5~20个字符',
        'cat_id.require' => '请先添加类型',
        'content.require' => '内容不可为空',
        'abstract.length' => '摘要不可超过150个字符'
    ];
}
